package vue;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import modele.CKModel;
import application.Consts;
import controleur.ControleBtnC0;

public class PanelC0 extends JPanel {
	
	CKModel<String, String> _modele;
	VueEditeurCK _vue;

	static final long serialVersionUID = 12345;
	private JLabel lblC0;
	private JTextField txtC0;
	private JLabel lblErrorC0;

	private JButton btnValiderC0;


	public PanelC0(CKModel<String, String> modele, VueEditeurCK vue){
		
		this._modele = modele;
		this._vue = vue;
		
		// Construct the Layout
		this.setLayout(new BorderLayout(5,5));
		
		// The label
		lblC0 = new JLabel(Consts.initialC, JLabel.CENTER);
		this.add(lblC0, BorderLayout.LINE_START);
		
		// The TextField
		txtC0 = new JTextField(40);
		txtC0.addKeyListener(new ControleBtnC0(_modele, _vue));
		this.add(txtC0, BorderLayout.CENTER);


		
		// Error label
		lblErrorC0 = new JLabel("");
		lblErrorC0.setPreferredSize(new Dimension(200,30));
		lblErrorC0.setForeground(Color.RED);
		this.add(lblErrorC0, BorderLayout.LINE_END);
		
		// OK Button
		btnValiderC0 = new JButton("Valider");
		btnValiderC0.addActionListener(new ControleBtnC0(_modele, _vue));
		this.add(btnValiderC0, BorderLayout.PAGE_END);
				
	}
	
	public String getTextC0(){
		return this.txtC0.getText();
	}

	/**
	 * @param lblErrorC0 the lblErrorC0 to set
	 */
	public void setLblErrorC0(String erreur) {
		this.lblErrorC0.setText(erreur);
	}

	/**
	 * @return the lblErrorC0
	 */
	public JLabel getLblErrorC0() {
		return lblErrorC0;
	}

	
	public JButton getBtnValiderC0() {
		return btnValiderC0;
	}


}